/*  BEGIN_FILE_HDR
******************************************Copyright(C)*****************************************
*
*                                       YKXH  Technology
*
***********************************File Info***************************************************
*   File Name       @: Common.h
************************************************************************************************
*   Project/Product @: Common
*   Title           @: This is Common Head File
*   Author          @: zhongliang.Yang 
************************************************************************************************
*   Description     @: This is common module for different driver 
*                     
************************************************************************************************
*   Limitations     @: None
*
************************************************************************************************
*
************************************************************************************************
*   Revision History:
* 
*   Version     Date          Initials           CR#         Descriptions
*   --------    -----------   ----------------   --------    -----------------------
*   1.0         2018/05/29    zhongliang.yang    N/A         Original 
*   1.1         xxxx/xx/xx    xxxxx              N/A         xxxxxxxx 
*     
************************************************************************************************
* END_FILE_HDR*/
#ifndef COMMON_H
#define COMMON_H

/*Include files*/
#include "YKSTDDEF.h"
#include "YKMCUDEF.h"
#include "CommonMacroDefine.h"

#ifdef COMMON_C
#define COMMONEXT   
#else
#define COMMONEXT  extern
#endif 
 

#define COMMON_OVER_TIME                    (1U)
#define COMMON_NOT_OVER_TIME                (0U)



/*macro function definition*/
#define GET_MAX_VAL(a,b)  (((a) < (b)) ? (b) : (a))

#define SET_BIT(Offset)   SET_BIT_8U(Offset)
#define CLR_BIT(Offset)   CLR_BIT_8U(Offset)

#define IO_BYTE(addr)     (*((volatile UINT8*)(addr))) 
#define IO_WORD(addr)     (*((volatile UINT16*)(addr)))


/* Function Declaration  */
COMMONEXT UINT8  SET_BIT_8U(UINT8 x);
COMMONEXT UINT8  CLR_BIT_8U(UINT8 x);
COMMONEXT UINT16 SET_BIT_16U(UINT8 x);
COMMONEXT UINT16 CLR_BIT_16U(UINT8 x) ;

COMMONEXT  void  Dly( UINT16 ParaDly );
COMMONEXT UINT8  OverTimeCheckByte(volatile UINT8 *pChkByte, UINT8 ChkBitsMask, UINT8 ChkVal, UINT16 ChkTime);
COMMONEXT UINT8  OverTimeCheckWord(volatile UINT16 *pChkByte, UINT16 ChkBitsMask, UINT16 ChkVal, UINT16 ChkTime);
COMMONEXT UINT8 OverTimeCheckLong(volatile UINT32 *pChkByte, UINT32 ChkBitsMask, UINT32 ChkVal, UINT16 ChkTime);
#endif  
